<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改著作')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-work-edit" th:object="${lhqWork}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">序号：</label>
                <div class="col-sm-8">
                    <input name="serialNumber" th:field="*{serialNumber}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">类别：</label>
                <div class="col-sm-8">
                    <select id="category" name="category" class="form-control" type="text"></select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">著作名称：</label>
                <div class="col-sm-8">
                    <input name="titleOfWork" th:field="*{titleOfWork}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">ISBN/CIP：</label>
                <div class="col-sm-8">
                    <input name="isbnCip" th:field="*{isbnCip}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">出版社：</label>
                <div class="col-sm-8">
                    <input name="press" th:field="*{press}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">主编：</label>
                <div class="col-sm-8">
                    <input name="chiefEditor" th:field="*{chiefEditor}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">副主编：</label>
                <div class="col-sm-8">
                    <input name="deputyEditorInChief" th:field="*{deputyEditorInChief}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">编者：</label>
                <div class="col-sm-8">
                    <input name="editor" th:field="*{editor}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">出版时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="publicationTime" th:value="${#dates.format(lhqWork.publicationTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group" hidden>
                <label class="col-sm-3 control-label">赋分：</label>
                <div class="col-sm-8">
                    <input name="naturalEndowments" th:field="*{naturalEndowments}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group" hidden>
                <label class="col-sm-3 control-label">奖励：</label>
                <div class="col-sm-8">
                    <input name="reward" th:field="*{reward}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group" hidden>
                <label class="col-sm-3 control-label">上传人：</label>
                <div class="col-sm-8">
                    <input name="applicant" th:field="*{applicant}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">文件：(doc/pdf)</label>
                <div class="col-sm-8">
                    <input type="hidden" name="file" th:field="*{file}">
                    <div class="file-loading">
                        <input class="form-control file-upload" id="file" name="file" type="file">
                    </div>
                </div>
            </div>
            <div class="form-group" hidden>
                <label class="col-sm-3 control-label">审批：</label>
                <div class="col-sm-8">
                    <input name="examineApprove" th:field="*{examineApprove}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group" hidden>
                <label class="col-sm-3 control-label">备案：</label>
                <div class="col-sm-8">
                    <input name="keepOnRecord" th:field="*{keepOnRecord}" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script th:inline="javascript">
        var prefix = ctx + "ruoyi/work";
        $("#form-work-edit").validate({
            focusCleanup: true
        });
        titleOfWorks();
        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-work-edit').serialize());
            }
        }

        $("input[name='publicationTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        function titleOfWorks(){
            var s =[[${lhqWork.category}]];
            var a = "请选择著作类别"
            $.ajax({
                url: prefix + "/category",
                type: "get",
                dataType:"json",
                data: {},
                success: function(data){
                    if(data.length>0){
                        $("#category").append("<option style='color: red'>"+ s +"</option>");
                        for(i in data){
                            $("#category").append("<option>"+data[i].category+"</option>");
                        }
                    }else{
                        $("#category").append("<option>暂无数据</option>")
                    }
                },
            })}

        $(".file-upload").each(function (i) {
            var val = $("input[name='" + this.id + "']").val()
            $(this).fileinput({
                'uploadUrl': '/common/upload',
                initialPreviewAsData: true,
                initialPreview: [val],
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
            $(this).fileinput('_initFileActions');
        });
    </script>
</body>
</html>